var app = getApp()
Page({
  data: {
    remark:''
  },
  onLoad: function (e) {
    var that = this;  
    if(e&&e.id){
      that.setData({
        id: e.id
      }) 
    }
  },
  remarkChange:function(e){
    var that = this;
    that.setData({
      remark:e.detail.value
    })
    console.log(that.data.remark);
  },
  submitReport: function () {
    var that = this;
    var amsId = that.data.id;
    var remark = that.data.remark;
    if(remark.length<=0){
      app.errorTip(that, "请输入报错内容", 2000);
      return;
    }
    wx.showLoading({
      title: '正在提交',
      mask: true,
      time: 100000
    })
    wx.request({
      url: app.globalData.requestUrl,
      data: {
        map: 'applet_mobile_report_error',
        amsId: amsId,
        remark: remark
      },
      success: function (res) {
        console.log(res.data);
        if (res.data.ec == 200) {
          that.setData({
            remark:''
          })
          wx.showModal({
            title: '提示',
            content: res.data.data.msg,
            showCancel:false,
            success: function (res) {
              if (res.confirm) {
                wx.navigateBack({
                  delta: 1
                })
              }
            }
          })
        } else {
          console.log(res.data)
          app.errorTip(that, res.data.em, 2000);
        }
      },
      complete: function () {
        wx.hideLoading();
      }
    });
  }
})